<template>
  <!-- 配件销售明细单 -->
  <div>
    <FilterTable
      ref="table"
      height="auto"
      columnsRef="part_partPurchase_queryR3DialogTable12"
      :dataSource="dataList"
      :isMemoryPagination="true"
      :isSelectColumn="false"
      :columns="tableColumns"
      :onColumnsChange="columns => (this.tableColumns = columns)"
    >
      <!-- :params="fetchParams"
      :fetchapi="fetchApi" -->
      <!-- :datakey="'rows'" -->
    </FilterTable>
    <div class="bottomBtnWrap">
      <el-button @click="handleClose">关 闭</el-button>
    </div>
  </div>
</template>

<script>
import { quertR3Log, queryAllOrderTypeInfo } from '@/api/part/partPurchase/purchaseOrder';
import { getSaleOrderDetailList, partSalesItem } from '@/api/part/report/salessettlement';
// import { partSalesItem } from '@/api/part/partOut/partSales/index.js';
export default {
  props: {
    orderNo: {
      type: String
    }
  },
  data() {
    return {
      fetchApi: partSalesItem,
      fetchParams: { xhrAbort: true },
      tableColumns: this.createTableColumns(),
      // orderTypeList: {}, //所有订单类型(翻译用)
      dataList: [] // 日志列表
    };
  },
  created() {
    this.querySaleOrderDetailList();
  },
  // mounted() {
  //   this.querySaleOrderDetailList();
  // },
  methods: {
    createTableColumns() {
      return [
        {
          title: '备/附件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '批号',
          dataIndex: 'PART_BATCH_NO',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '备/附件名称',
          dataIndex: 'PART_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '销售单价',
          dataIndex: 'PART_SALES_PRICE',
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '销售数量',
          dataIndex: 'PART_QUANTITY',
          sorter: true,
          filter: true,
          filterType: 'number',
          precision: 2,
          summation: true
        },
        {
          title: '计量单位',
          dataIndex: 'UNIT_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    // 查询所有订单类型
    async queryAllOrderTypeInfoList() {
      let res = await queryAllOrderTypeInfo();
      let obj = {};
      res.data.map(item => {
        obj[item.partTypeNo] = item.partTypeName;
      });
      this.orderTypeList = obj;
    },
    // 查询r3列表
    async querySaleOrderDetailList() {
      var roNo = this.orderNo;
      let res = await partSalesItem({ orderNo: this.orderNo });
      this.dataList = res.data;
      // this.fetchParams = Object.assign({}, { xhrAbort: false }, { orderNo: this.orderNo });

      // this.$refs.table.START_LOADING();
      // let res = await getSaleOrderDetailList(this.orderNo);
      // this.$refs.table.STOP_LOADING();
      // if (res.resultCode == 200) {
      //   this.dataList = res.data;
      // }
    },
    handleClose() {
      this.$emit('close');
    }
  }
};
</script>

<style scoped>
.bottomBtnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
.btnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
</style>
